/**
 * 详情对话框
 */
var BasicWarehouseInfoDlg = {
    data: {
        warehouseOperateId: "",
        warehouseOperateName: "",
        warehouseName: "",
        warehouseNumber: "",
        warehouseCanmeasure: "",
        warehouseMeasure: "",
        warehouseAddress: "",
        longitude: "",
        latitude: "",
        warehouseContacts: "",
        warehouseType: "",
        warehouseState: "",
        warehouseNotes: "",
        version: "",
        createTime: "",
        updateTime: "",
        createUser: "",
        updateUser: "",
        warehouseXlbId:""
    }
};

layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/basicWarehouse/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('basicWarehouseForm', result.data);

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/basicWarehouse/editItem", function (data) {
            Feng.success("更新成功！");
            window.location.href = Feng.ctxPath + '/basicWarehouse/index_hx'
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });
    
    //选择位置
    $("#selectlocation").click(function(){
        layer.open({
            type: 2,
            title: '选择地址',
            area: ['800px', '550px'],
            content: Feng.ctxPath + '/basicWarehouse/toChoiceAddress?warehouseAddress=' + $("#warehouseAddress").val(), 
            end: function () {
				if(BasicWarehouseInfoDlg.data.warehouseAddress != null && BasicWarehouseInfoDlg.data.warehouseAddress != ''){
	                $("#warehouseAddress").val(BasicWarehouseInfoDlg.data.warehouseAddress);//地址
	                $("#longitude").val(BasicWarehouseInfoDlg.data.longitude);//经度
	                $("#latitude").val(BasicWarehouseInfoDlg.data.latitude);//维度
				}
            }
        });
    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/basicWarehouse/index_hx'
    });

});